<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <body>

        <ui:composition template="./report_list.xhtml">

            <ui:define name="report">

                <p:panel header="Search Bills" >
                    <f:facet name="header">
                        <h:panelGrid columns="1" >
                            <h:panelGrid columns="7" >

                                <h:outputLabel value="From Date"/>
                                <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{searchController.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >      
                                </p:calendar>
                                <h:outputLabel value="To Date"/>
                                <p:calendar id="toDate" value="#{searchController.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >                                                                              
                                </p:calendar>
                                <p:commandButton id="btnSearch2" ajax="false" value="Search" action="#{searchController.createPatientInvestigationsTableAll()}" onclick="onSubmitButton();" />
                                <p:commandButton ajax="false" value="Download as Excel" >
                                    <p:dataExporter target="tblBills" type="xls" fileName="test_list" ></p:dataExporter>
                                </p:commandButton>
                            </h:panelGrid>
                            <h:panelGrid columns="4" >
                                <h:outputLabel value="Bill No"/>
                                <h:outputLabel value="Patient Name"/>
                                <h:outputLabel value="Patient Phone"/>                               
                                <h:outputLabel value="Investigation Name"/>
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.billNo}" />
                                <p:inputText autocomplete="off" value="#{searchController.searchKeyword.patientName}" />
                                <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.patientPhone}" />
                                <p:inputText autocomplete="off" value="#{searchController.searchKeyword.itemName}"/>
                                <h:outputLabel value="Report Department"/>
                                <h:outputLabel value="Bill Department"/>
                                <h:outputLabel value="BHT"/>
                                <h:outputLabel/>
                                <p:autoComplete completeMethod="#{departmentController.completeDept}" styleClass="shortinput2"
                                                var="dept" itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" 
                                                value="#{searchController.reportKeyWord.department}" converter="departmentConverter"/>
                                <p:autoComplete completeMethod="#{departmentController.completeDept}" styleClass="shortinput2"
                                                var="dept" itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" 
                                                value="#{searchController.reportKeyWord.departmentFrom}" converter="departmentConverter"/>
                                <p:autoComplete converter="admis" widgetVar="aPt" id="acPt" forceSelection="true" styleClass="shortinput2"
                                                value="#{searchController.patientEncounter}"
                                                completeMethod="#{admissionController.completePatientAll}" 
                                                var="myItem" itemValue="#{myItem}" 
                                                itemLabel="#{myItem.bhtNo}" 
                                                size="30"  >
                                    <p:column>
                                        <p:outputLabel value="#{myItem.bhtNo}" />
                                    </p:column>
                                    <p:column>
                                        <p:outputLabel value="#{myItem.patient.person.nameWithTitle}" />

                                    </p:column>
                                    <p:column>
                                        <h:outputLabel value="#{myItem.currentPatientRoom.roomFacilityCharge.name}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputLabel value="Discharged"  rendered="#{myItem.discharged}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputLabel value="Discharged"  rendered="#{myItem.paymentFinalized}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputLabel  value="Cancelled"  rendered="#{myItem.retired}"/>
                                    </p:column>
                                </p:autoComplete>

                            </h:panelGrid>
                        </h:panelGrid>
                    </f:facet>




                    <p:dataTable  id="tblBills" value="#{searchController.patientInvestigations}" var="pi" rowIndexVar="i" 
                                  rows="20"
                                  paginator="true"
                                  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                  rowsPerPageTemplate="20, 50, 100, 1000, 1500">

                        <p:column  headerText="Bill Date" styleClass="alignTop" >
                            <h:outputLabel 
                                value="#{pi.billItem.bill.billDate}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                                <f:convertDateTime pattern="dd MMMM yyyy" ></f:convertDateTime>
                            </h:outputLabel>
                        </p:column>
                        <p:column  headerText="Bill Time" styleClass="alignTop" >
                            <h:outputLabel 
                                value="#{pi.billItem.bill.billDate}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                                <f:convertDateTime pattern="hh:mm a" ></f:convertDateTime>
                            </h:outputLabel>
                        </p:column>
                        <p:column  headerText="Bill No" styleClass="alignTop" sortBy="#{pi.billItem.bill.insId}" filterBy="#{pi.billItem.bill.insId}" filterMatchMode="contains" >
                            <h:outputLabel 
                                value="#{pi.billItem.bill.insId}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                            </h:outputLabel>
                        </p:column>
                        <p:column  headerText="Client" styleClass="alignTop"  sortBy="#{pi.billItem.bill.patient.person.nameWithTitle}" filterBy="#{pi.billItem.bill.patient.person.nameWithTitle}" filterMatchMode="contains" >
                            <h:outputLabel 
                                value="#{pi.billItem.bill.patient.person.nameWithTitle}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                            </h:outputLabel>
                        </p:column>
                        <p:column  headerText="Phone" styleClass="alignTop"  sortBy="#{pi.billItem.bill.patient.person.phone}" filterBy="#{pi.billItem.bill.patient.person.phone}" filterMatchMode="contains" >
                            <h:outputLabel 
                                value="#{pi.billItem.bill.patient.person.phone}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                            </h:outputLabel>
                        </p:column>
                        <p:column  headerText="Test" styleClass="alignTop"  sortBy="#{pi.billItem.item.name}" filterBy="#{pi.billItem.item.name}" filterMatchMode="contains" >
                            <h:outputLabel 
                                value="#{pi.billItem.item.name}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                            </h:outputLabel>
                        </p:column>
                        <p:column  headerText="Referred By" styleClass="alignTop"  sortBy="#{pi.billItem.bill.referredInstituteOrDoctor.name}" filterBy="#{pi.billItem.bill.referredInstituteOrDoctor.name}" filterMatchMode="contains" >
                            <h:outputLabel 
                                value="#{pi.billItem.bill.referredInstituteOrDoctor.name}" 
                                styleClass="#{pi.billItem.bill.cancelled or pi.billItem.transRefund ? 'redtext':''}">
                            </h:outputLabel>
                        </p:column>

                    </p:dataTable>

                </p:panel>



            </ui:define>

        </ui:composition>

    </body>
</html>
